{#首页信息,继承基础模板#}
{% extends 'base.html' %}
{% block title %}首页{% endblock %}
{% block main %}
    <br>
{#    循环展示所有文章标题以及简介,不展示详细内容#}
    {% for rp in arc_posts %}
        <a href="/post/?id={{ rp.id }}" target="_blank">
        <div class="post">
{#        文章标题#}
            <h1 class="title">{{ rp.title }}</h1>
            <h6 class="modified">最后修改时间: {{ rp.modified }}</h6>&emsp;
            <h3 class="desc">说明 :<br>&emsp;{{ rp.desc | safe }}</h3><br>
            <h6 class="created">创建时间: {{ rp.created }}</h6><br>
        </div>
        </a>
        <br>
    {% endfor %}
{#    翻页功能#}
{#    判断后台是否将类别传送过来,如果有则执行以下代码:#}
    {% if index_category %}

        <table style="margin-left: 35%">
            <tr>
                <td id="page">
{#                a:点击后将首页从url传到后台#}
                    <a href="/index/?page=1">
                        <input type="button" value="首页">
                    </a>
{#                判断是否有上一页#}
                    {% if arc_posts.has_previous %}
{#                        如果有上一页,点击后会将上一页页码传到后台#}
                        <a href="/index/?page={{ arc_posts.previous_page_number }}&category={{ index_category }}">
                            <input type="button" value="上一页">
                        </a>
                        {% else %}
{#                        当前页不存在上一页时候会跳转到第一页#}
                        <a href="/index/?page=1&category={{ index_category }}">
                            <input type="button" value="上一页">
                        </a>
                    {% endif %}
{#                &nbsp;循环显示所有页码#}
                {% for i in arc_posts.paginator.page_range %}
{#                    判断是否为当前页,如果是当前页则普通展示并加粗#}
                    {% if i == arc_posts.number %}
                        <b>&nbsp;&nbsp;{{ i }}&nbsp;</b>
{#                        如果不是当前页则附带超链接展示#}
                        {% else %}
{#                        超链接用于点击某一页页码时候将页码传到后台#}
                        <a href="/index/?page={{ i }}&category={{ index_category }}">[{{ i }}]</a>
                    {% endif %}
                {% endfor %}

{#                判断是否有下一页,如果有下一页点击后则将下一页页码传到后台#}
                {% if arc_posts.has_next %}
                    <a href="/index/?page={{ arc_posts.next_page_number }}&category={{ index_category }}">
                    <input type="button" value="下一页">
                    </a>
                {% else %}
{#                    当不存在下一页时候,只会显示最后一页#}
                    <a href="/index/?page={{ arc_posts.paginator.num_pages }}&category={{ index_category }}">
                        <input type="button" value="下一页">
                    </a>
                {% endif %}
{#                末页页码,点击后传到后台#}
                <a href="/index/?page={{ arc_posts.paginator.num_pages }}&category={{ index_category }}">
                    <input type="button" value="末页">
                </a>
                </td>
            </tr>
        </table>
        {#----------------如果没有收到后台传过来的类别则执行以下代码,与上边的区别在于将传回后台的分类代码:  &category={{ index_category }}  替换成了: &created={{ index_created }}  )避免报错-----------------------------------------#}
        {% elif index_created %}
        <table style="margin-left: 35%">
            <tr>
                <td id="page">
                    <a href="/index/?page=1&created={{ index_created }}">
                        <input type="button" value="首页">
                    </a>
                    {% if arc_posts.has_previous %}
                        <a href="/index/?page={{ arc_posts.previous_page_number }}&created={{ index_created }}">
                            <input type="button" value="上一页">
                        </a>
                        {% else %}
{#                        当前页不存在上一页时候会跳转到第一页#}
                        <a href="/index/?page=1&created={{ index_created }}">
                            <input type="button" value="上一页">
                        </a>
                    {% endif %}
                &nbsp;
{#                {{ arc_posts.number }}/{{ arc_posts.paginator.num_pages }}#}
                &nbsp;
                {% for i in arc_posts.paginator.page_range %}
                    {% if i == arc_posts.number %}
                        <b>&nbsp;[{{ i }}] &nbsp;</b>
                        {% else %}
                        <a href="/index/?page={{ i }}&created={{ index_created }}">[{{ i }}]</a>
                    {% endif %}
                {% endfor %}

                {% if arc_posts.has_next %}
                    <a href="/index/?page={{ arc_posts.next_page_number }}&created={{ index_created }}">
                    <input type="button" value="下一页">
                    </a>
                {% else %}
{#                    当不存在下一页时候,只会显示最后一页#}
                    <a href="/index/?page={{ arc_posts.paginator.num_pages }}&created={{ index_created }}">
                        <input type="button" value="下一页">
                    </a>
                {% endif %}
                <a href="/index/?page={{ arc_posts.paginator.num_pages }}&created={{ index_created }}">
                    <input type="button" value="末页">
                </a>
                </td>
            </tr>
        </table>
        {#----------------如果没有收到后台传过来的类别则执行以下代码,与上边的区别在于点击各种翻页功能时候不会将空类别传到后台去,(超链接中去除掉了代码:  &category={{ index_category }}  )避免出现BUG-----------------------------------------#}
        {% else %}
        <table style="margin-left: 35%">
            <tr>
                <td id="page">
                    <a href="/index/?page=1">
                        <input type="button" value="首页">
                    </a>
                    {% if arc_posts.has_previous %}

                        <a href="/index/?page={{ arc_posts.previous_page_number }}">
                            <input type="button" value="上一页">
                        </a>
                        {% else %}
{#                        当前页不存在上一页时候会跳转到第一页#}
                        <a href="/index/?page=1">
                            <input type="button" value="上一页">
                        </a>
                    {% endif %}
                &nbsp;
{#                {{ arc_posts.number }}/{{ arc_posts.paginator.num_pages }}#}
                &nbsp;
                {% for i in arc_posts.paginator.page_range %}
                    {% if i == arc_posts.number %}
                        <b>&nbsp;[{{ i }}] &nbsp;</b>
                        {% else %}
                        <a href="/index/?page={{ i }}">[{{ i }}]</a>
                    {% endif %}
                {% endfor %}

                {% if arc_posts.has_next %}
                    <a href="/index/?page={{ arc_posts.next_page_number }}">
                    <input type="button" value="下一页">
                    </a>
                {% else %}
{#                    当不存在下一页时候,只会显示最后一页#}
                    <a href="/index/?page={{ arc_posts.paginator.num_pages }}">
                        <input type="button" value="下一页">
                    </a>
                {% endif %}
                <a href="/index/?page={{ arc_posts.paginator.num_pages }}">
                    <input type="button" value="末页">
                </a>
                </td>
            </tr>
        </table>

    {% endif %}

{% endblock %}